Created: 2022-07-09
Tags: #fleeting
Defines
Say, file named note.dtd
<!DOCTYPE note [ <!ELEMENT note (to,from,heading,body)> <!ELEMENT to (#PCDATA)> <!ELEMENT from (#PCDATA)> <!ELEMENT heading (#PCDATA)> <!ELEMENT body (#PCDATA)> ]>
^- We use this DTD above to -^
.dtdLet's say we validate the XML doc note with note.dtd
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE note SYSTEM "note.dtd">
<note>
<to>falcon</to>
<from>feast</from>
<heading>hacking</heading>
<body>XXE attack</body>
</note>
Basically explanation of the note.dtd file
!DOCTYPE note -> Defines root element of document named note
!ELEMENT note (to, from, heading, body)
^-> Defines that note element must contain:
to, from, heading, body
!ELEMENT to (#PCDATA) defines type element to be "#PCDATA"
!ELEMENT to (#)
Basically to, from, heading, body elements will be defined as "#PCDATA"
NOTE: #PCDATA means parseable character data.